package app.nbdevices.timing;

import door.faultHandler.DoorFaultHandler;
import ele.faultHandler.EleFaultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import water.faultHandler.WaterFaultHandler;
import yangan.faultHandler.YanganFaultHandler;

import java.time.LocalDateTime;

@Component
public class CycleCheck {

    @Autowired
    EleFaultHandler eleFaultHandler;
    @Autowired
    WaterFaultHandler waterFaultHandler;
    @Autowired
    YanganFaultHandler yanganFaultHandler;
    @Autowired
    DoorFaultHandler doorFaultHandler;

 //   @Scheduled(cron = "0 0 0 7 7 ?")
      @Scheduled(cron = "5 24 15 * * ?")
   //   @Scheduled(cron = "0 47 * * * ?")
    public void eleCycleCheck(){
        System.out.println("当前时间:"+ LocalDateTime.now()+"  任务execute1对应的线程名: "+Thread.currentThread().getName());
        System.out.println("+++++++++++++电表定 时检查++++++++++++++++++");
        eleFaultHandler.dropLine();
    }

   //@Scheduled(cron = "5 24,26,28 12 * * ?")@Scheduled(cron = "3 * * * * ?")

  // @Scheduled(cron = "15 36 12 * * ?")
//  @Scheduled(cron = "0 0 0 7 7 ?")
  @Scheduled(cron = "15 36 16 * * ?")
    public void waterCycleCheck(){
        System.out.println("当前时间:"+ LocalDateTime.now()+"  任务execute1对应的线程名: "+Thread.currentThread().getName());
        System.out.println("+++++++++++++水表定 时检查++++++++++++++++++");
        waterFaultHandler.dropLine();
    }


   // @Scheduled(cron = "36 * * * * ?")
   // @Scheduled(cron = "0 0 0 7 7 ?")
     @Scheduled(cron = "25 48 17 * * ?")
//     @Scheduled(cron = "00 * * * * ?")
    public void yanganCycleCheck(){
        System.out.println("当前时间:"+ LocalDateTime.now()+"  任务execute1对应的线程名: "+Thread.currentThread().getName());
        System.out.println("+++++++++++++烟感定 时检查++++++++++++++++++");
        yanganFaultHandler.dropLine();
    }

   // @Scheduled(cron = "05 05 18 * * ?")
    @Scheduled(cron = "0 45 * * * ?")
    public void menjinCycleCheck(){
        System.out.println("当前时间:"+ LocalDateTime.now()+"  任务execute1对应的线程名: "+Thread.currentThread().getName());
        System.out.println("+++++++++++++门禁定 时检查++++++++++++++++++");
        doorFaultHandler.dropLine();
    }
}
